//
//  BaseTableViewController.swift
//  bboySinaWeibo
//
//  Created by apple on 15/11/11.
//  Copyright © 2015年 apple. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {
    
    
    //添加用户是否登录标志
    var userLogin = false
    
    var visitorView : VisitorLoginView?
    //这个方法是苹果准们为手动创建视图而设置的 如果实现了这个方法 就不会走storyboard 和 xib
    override func loadView() {
        
        userLogin ? super.loadView() :loadVisitorView()
        
    }
    
    func loadVisitorView(){
        
        //设置代理
        
        visitorView = VisitorLoginView()
        
        visitorView?.visitorDelegate = self
        
        view = visitorView
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: "visitorWillLogin")
        
         self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    //MARK 代理方法
    func visitorWillLogin() {
        
        
        let vc = OauthViewController()
        
        let nav = UINavigationController(rootViewController: vc)
        
        self.navigationController?.presentViewController(nav, animated: true, completion: nil)
    
    }
    func visitorWillRegister() {
        
        print("注册")
    }
    
}
